package cn.shopifymall.hw_od;

import org.junit.Test;

import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Author 孤风雪影
 * @Email gitee.com/efairy520
 * @Date 2023/3/12 22:03
 * @Version 1.0
 */
public class Notebook {

    /**
     * HJ1 字符串最后一个单词的长度
     */
    @Test
    public void test001() {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] split = line.split(" ");
        String lastWord = split[split.length - 1];
        int length = lastWord.length();
        System.out.print(length);
    }

    /**
     * 计算某字符出现次数
     */
    @Test
    public void test002() {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String targetChar = scanner.nextLine();
        int count = 0;
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if (targetChar.equalsIgnoreCase(c + "")) {
                count ++;
            }
        }
        System.out.print(count);
    }

    /**
     * 明明随机数
     */
    @Test
    public void test003() {
        Scanner scanner = new Scanner(System.in);
        String inputCountString = scanner.nextLine();
        int inputCount = Integer.parseInt(inputCountString);
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < inputCount; i++) {
            set.add(Integer.parseInt(scanner.nextLine()));
        }
        List<Integer> collect = set.stream().sorted((a,b)-> a - b).collect(Collectors.toList());
        for (Integer integer : collect) {
            System.out.println(integer);
        }
    }
    
    
}
